#include "FollowPath.h"
#include "Agent.h"
#include "SteeringOutput.h"

namespace Engine
{
	FollowPath::FollowPath() : m_actualTarget(nullptr) { m_target = new Agent; }

	void FollowPath::SetTarget(Agent* t)
	{
		m_actualTarget = t;
	}

	void FollowPath::Update(SteeringOutput* output)
	{
		m_pointOnPath = m_path->MapPointToPath(m_parent->GetPos());

		Vec3 targetPos = m_pointOnPath + m_distOffset;

		Vec3 mapTargetPos = m_path->MapPointToPath(targetPos);

		// ---> debug line purposes
		//
		m_path->SetT(mapTargetPos);

		Seek::m_target->SetPos(mapTargetPos);
		Seek::Update(output);
	}

	void FollowPath::SetDistOffset(float distOffset)
	{
		m_distOffset = distOffset;
	}

	void FollowPath::SetPath(Path* path)
	{
		m_path = path;
	}

	FollowPath::~FollowPath()
	{
		if(m_target) delete m_target;
	}
}